package com.sec.etech.org.controller;

import org.openbpm.base.api.aop.annotion.CatchErr;
import org.openbpm.base.api.response.impl.ResultMsg;
import org.openbpm.base.rest.ControllerTools;
import org.openbpm.base.rest.util.RequestUtil;
import org.openbpm.org.core.manager.ResRoleManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/etech/resRole")
public class EtechResRoleController extends ControllerTools {

    @Resource(name = "etechResRoleManager")
    ResRoleManager resRoleManager;

    /**
     * 保存角色资源分配信息
     *
     * @param request
     * @param response
     * @throws Exception void
     * @throws
     */
    @RequestMapping("save")
    @CatchErr("对角色资源分配操作失败")
    public ResultMsg<String> save(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String roleId = RequestUtil.getString(request, "roleId");
        String systemId = RequestUtil.getString(request, "systemId");
        String resIds = RequestUtil.getString(request, "resIds");

        resRoleManager.assignResByRoleSys(resIds, systemId, roleId);
        return getSuccessResult( " 添加角色资源分配成功");
    }
}
